﻿using RaytracerLib.MathLib;
using System.Collections.Generic;
using System.Drawing;

namespace RaytracerLib.Samplers
{
    public class GridSampler : UniformSampler
    {
        public override IEnumerable<Vector2> GetSamples(Rectangle a_rect)
        {
            int samples_x = a_rect.Width * Subresolution;
            int samples_y = a_rect.Height * Subresolution;

            for (int y = 0; y < samples_y; y++)
            {
                for (int x = 0; x < samples_x; x++)
                {
                    yield return new Vector2(
                        a_rect.Left + (x + 0.5) / Subresolution, 
                        a_rect.Top + (y + 0.5) / Subresolution);
                }
            }
        }

        public override SamplerType SamplerType 
        {
            get
            {
                return SamplerType.Grid;
            }
        }
    }
}